﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using Ext.Net;

namespace DemoExtNet.UserControls
{
    public partial class UCPreviewPDF : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
        public void Call()
        {
          
            //btnPreview.FireEvent("OnClick");
        }
        protected void Preview(object sender, EventArgs e)
        {
            Context.Response.Buffer = false;
            FileStream file = null;
            byte[] mybuff = new byte[1024];
            long count;
            file = File.OpenRead(@"E:\Book\Manning.ASP.NET.MVC.in.Action.Sep.2009.pdf");
            while ((count = file.Read(mybuff, 0, mybuff.Length)) > 0)
            {
                if (Context.Response.IsClientConnected)
                {
                    Context.Response.OutputStream.Write(mybuff, 0, mybuff.Length);
                    Context.Response.Flush();
                }
            }
            
        }
    }
}